View Javadoc

1   /*
2      Licensed under the Apache License, Version 2.0 (the "License");
3      you may not use this file except in compliance with the License.
4      You may obtain a copy of the License at
5   
6        http://www.apache.org/licenses/LICENSE-2.0
7   
8      Unless required by applicable law or agreed to in writing, software
9      distributed under the License is distributed on an "AS IS" BASIS,
10     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11     See the License for the specific language governing permissions and
12     limitations under the License.
13  */
14  package uk.nhs.interoperability.client.samples.cda;
15  
16  import uk.nhs.interoperability.consumer.AbstractRoutedMessageServlet;
17  import uk.nhs.interoperability.consumer.ITKMessageConsumer;
18  import uk.nhs.interoperability.infrastructure.ITKMessagingException;
19  import uk.nhs.interoperability.payload.ITKMessage;
20  import uk.nhs.interoperability.util.Logger;
21  
22  /**
23   * The Class CDARepository.
24   *
25   * @author Michael Odling-Smee
26   * @author Nicholas Jones
27   * @since 0.1
28   */
29  public class CDARepository extends AbstractRoutedMessageServlet implements ITKMessageConsumer{
30  
31  	/** The Constant serialVersionUID. */
32  	private static final long serialVersionUID = -541728545823668074L;
33  
34  	/* (non-Javadoc)
35  	 * @see uk.nhs.interoperability.consumer.ITKMessageConsumer#onMessage(uk.nhs.interoperability.payload.ITKMessage)
36  	 */
37  	public void onMessage(ITKMessage request) {
38  		Logger.trace("This is CDA Repository receiving a message:onMessage()");
39  		String docId = request.getMessageProperties().getBusinessPayloadId();
40  		if (docId.substring(0,5).equals("uuid_")){
41  			docId = docId.substring(5);
42  		}
43  		DocStore.putDocument(docId, request.getBusinessPayload());
44  		Logger.trace("added document "+docId+" to repository.");
45  		
46  		// NOTE : BUSINESS ACKS ARE NOT SUPPORTED BY THIS VERSION
47  	}
48  
49  	/* (non-Javadoc)
50  	 * @see uk.nhs.interoperability.consumer.ITKMessageConsumer#onSyncMessage(uk.nhs.interoperability.payload.ITKMessage)
51  	 */
52  	public ITKMessage onSyncMessage(ITKMessage request)	throws ITKMessagingException {
53  		throw new ITKMessagingException(ITKMessagingException.INVALID_MESSAGE_CODE, "Synchronous execution not supported");
54  	}
55  
56  	/* (non-Javadoc)
57  	 * @see uk.nhs.interoperability.consumer.AbstractRoutedMessageServlet#getMessageConsumer()
58  	 */
59  	@Override
60  	public ITKMessageConsumer getMessageConsumer() {
61  		return this;
62  	}
63  
64  }